home *** CD-ROM | disk | FTP | other *** search
- #ifndef lint
- static char rcsid[] = "$Header: list.c,v 1.3 87/02/12 11:02:40 schoch Exp $";
- #endif
-
- /* list.c */
- #include "constants.h"
-
- #ifndef FALSE
- #define FALSE 0
- #define TRUE 1
- #endif
-
- struct IN
- {
- int i;
- struct IN *n;
- };
- typedef struct IN *LIST;
-
- LIST
- linsert (list, number)
- LIST list;
- int number;
- {
- LIST cell;
-
- char *malloc ();
- cell = (LIST) malloc (sizeof (struct IN));
- cell->i = number;
- cell->n = list;
- return cell;
- }
-
- LIST
- lmember (number, list)
- int number;
- LIST list;
- {
- while (list != NIL) {
- if (list->i == number)
- return list;
- list = list->n;
- }
- return FALSE;
- }
-
- lfront (sublist, list)
- LIST sublist, list; /* both must be non-NIL */
- /* Allows easy deletion, when combined with lmember. Violent. */
- {
- int n;
-
- n = list->i;
- list->i = sublist->i;
- sublist->i = n;
- }
-